﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication4
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        List<string> year = new List<string>();
        List<string> month = new List<string>();
        string gender = "男";
        string name = " ";
        string birthday = " ";
        bool[] hobby = new bool[] { false, false, false, false };
        string[] hobbyStr = new string[] { "唱歌", "跳舞", "rap", "篮球" };



        protected void Page_Load(object sender, EventArgs e)
        {
            if(DropDownList1.Items.Count ==0)
            {
                for (int i = 1970; i < 2021; i++)
                {
                    DropDownList1.Items.Add(i.ToString());

                }
                for (int i = 1; i <= 12; i++)
                {
                    DropDownList2.Items.Add(i.ToString());
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string Filename = FileUpload1.FileName;
                FileUpload1.SaveAs(Server.MapPath("") + "\\" + Filename);
                this.Image1.ImageUrl = Filename;
                this.Image2.ImageUrl = Filename;

                name = TextBox1.Text;
                if (RadioButtonList1.SelectedIndex != 0)
                {
                    gender = "女";
                }

                birthday = DropDownList1.SelectedValue + "-" + DropDownList2.SelectedValue;
                hobby[0] = CheckBox1.Checked;
                hobby[1] = CheckBox2.Checked;
                hobby[2] = CheckBox3.Checked;
                hobby[3] = CheckBox4.Checked;

                Label1.Text = name;
                Label2.Text = gender;
                Label3.Text = birthday;
                for (int i = 0; i < 4; i++)
                {
                    if (hobby[i])
                    {
                        Label4.Text += " " + hobbyStr[i];
                    }
                }
                Label5.Visible = true;
                Label5.Text = "您的卡片已经生成，请查看页面底部";
            }
            catch
            {
                Label5.Visible = true;
                Label5.Text = "请把信息填写完整";
            }


        }
    }
}